<?php 
class DomSmarty extends Smarty {

	
	
	public function __construct() {
		$this->compile_dir = SMARTY_COMPILE_DIR;
		$this->cache_dir = SMARTY_CACHE_DIR;
	}
	
	
	public function fetch( $templateFileLocation, $cacheId = NULL ) {
		try {
			return parent::fetch( $templateFileLocation, $cacheId );
		} catch( RuntimeException $e ) {
			if( !is_dir($this->compile_dir) ) {
				mkdir($this->compile_dir);
			}
			if( !is_dir($this->cache_dir) ) {
				mkdir($this->cache_dir);
			}
			return parent::fetch( $templateFileLocation, $cacheId );
		}
	}

}

?>